package dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

public class ConnectionFactory {
	
	Properties connInfo = new Properties();

	String driverName = "com.mysql.jdbc.Driver";
	String conUrl = "jdbc:mysql://localhost:3306/vc?useUnicode=yes&characterEncoding=UTF-8";
	String userDB = "root";
	String pwdDB = "6gh6st6";

	private static ConnectionFactory connectionFactory = null;

	private ConnectionFactory() {
		try {
			Class.forName(driverName);
			
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}
	
	public Connection getConnection() throws SQLException {
		Connection conn = null;
		conn = DriverManager.getConnection(conUrl, userDB, pwdDB);
		return conn;
	}

	public static ConnectionFactory getInstance() {
		if (connectionFactory == null) {
			connectionFactory = new ConnectionFactory();
		}
		return connectionFactory;
	}

}
